import type { RenderParams, Lifecycle } from "@/core/types";
import { Component, VueComponent } from "@/core/types";

// 抽象类
export abstract class VuePage<D = unknown, P = unknown, L = unknown> extends Component<D, P> implements Lifecycle<L> {
  private components: RenderParams = [];
  constructor(data: D = {} as D, props: P = {} as P) {
    super(data, props);
  }
  // 子类必须对抽象类的方法进行重写
  abstract getPath(): string;
  // 获取组件
  getComponents(): RenderParams {
    return this.components || [];
  }
  registerComponent(comp: VueComponent, params?: {}) {
    this.components.push({ comp, params: params || {} });
  }
}
